package thread;

import java.io.ObjectInputStream;

public class ThreadUse {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                System.out.println("我在工作..");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"t1");

        thread.start();
        long id = thread.getId();
        System.out.println(id);
        String name = thread.getName();
        System.out.println(name);
        Thread.State threadState = thread.getState();
        System.out.println("status:" + threadState);
        int threadPriority = thread.getPriority();
        System.out.println(threadPriority);
        System.out.println("isDeamon:"+thread.isDaemon());
        System.out.println("isAlive:" + thread.isAlive());
        try {
            Thread.sleep(8000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("isAlive:" + thread.isAlive());
        System.out.println("status:" + threadState);
    }
}
